package com.xique.park.api.factory;


import com.xique.common.core.domain.R;
import com.xique.park.api.RemoteParkConfigService;
import com.xique.park.api.dto.ParkConfigDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 日志服务降级处理
 *
 * @author xique
 */
@Component
public class RemoteParkConfigFallbackFactory implements FallbackFactory<RemoteParkConfigService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteParkConfigFallbackFactory.class);

    @Override
    public RemoteParkConfigService create(Throwable throwable)
    {
        log.error("服务调用失败:{}", throwable.getMessage());
        return new RemoteParkConfigService()
        {

            @Override
            public R<Boolean> saveParkConfig(ParkConfigDTO parkConfigDTO) {
                return R.fail("保存车场配置信息失败:" + throwable.getMessage());
            }
        };

    }
}
